f61a8c80bef960e1cb070d00dcc3260ebc813d45,app/src/main/java/com/greenaddress/greenbits/ui/TransactionActivity.java,TransactionActivity,replaceByFee,#TransactionItem#Coin#number#number#,344
Before Change
final List<TransactionInput> oldInputs = new ArrayList<>(tx.getInputs());
tx.clearInputs();
for (int i = 0; i < txItem.eps.size(); ++i) {
final Map<String, Object> ep = (Map) txItem.eps.get(i);
if (((Boolean) ep.get("is_credit"))) continue;
final TransactionInput oldInput = oldInputs.get((Integer) ep.get("pt_idx"));
final TransactionInput newInput = new TransactionInput(
Network.NETWORK,
null,
oldInput.getScriptBytes(),
oldInput.getOutpoint(),
Coin.valueOf(Long.valueOf((String) ep.get("value")))
);
newInput.setSequenceNumber(0);
tx.addInput(newInput);
}
final Coin oldFee = tx.getFee();
final Coin newFeeWithRate = feerate.multiply(txSize).divide(1000);
final Coin feeDelta = Coin.valueOf(Math.max(
newFeeWithRate.subtract(oldFee).longValue(),
requiredFeeDelta
));
Coin remainingFeeDelta = feeDelta;
final List<TransactionOutput> origOuts = new ArrayList<>(tx.getOutputs());
tx.clearOutputs();
for (int i = 0; i < txItem.eps.size(); ++i) {
final Map<String, Object> ep = (Map) txItem.eps.get(i);
if (!((Boolean) ep.get("is_credit"))) continue;
if (!((Boolean) ep.get("is_relevant")))
// keep non-change/non-redeposit intact
tx.addOutput(origOuts.get((Integer)ep.get("pt_idx")));
else {
if ((ep.get("subaccount") == null && subAccount == 0) ||
ep.get("subaccount").equals(subAccount))
change_pointer = (Integer) ep.get("pubkey_pointer");
// change/redeposit
final long value = Long.valueOf((String) ep.get("value"));
if (Coin.valueOf(value).compareTo(remainingFeeDelta) <= 0) {
// smaller than remaining fee -- get rid of this output
remainingFeeDelta = remainingFeeDelta.subtract(
Coin.valueOf(value)
After Change
final long requiredFeeDelta = txSize + tx.getInputs().size() * 4;
final List<TransactionInput> oldInputs = new ArrayList<>(tx.getInputs());
tx.clearInputs();
for (final JSONMap ep : txItem.eps) {
if (ep.getBool("is_credit"))
continue;
final TransactionInput oldInput = oldInputs.get(ep.getInt("pt_idx"));
final TransactionInput newInput = new TransactionInput(
Network.NETWORK,
null,
oldInput.getScriptBytes(),
oldInput.getOutpoint(),
ep.getCoin("value")
);
newInput.setSequenceNumber(0);
tx.addInput(newInput);
}
final Coin oldFee = tx.getFee();
final Coin newFeeWithRate = feerate.multiply(txSize).divide(1000);
final Coin feeDelta = Coin.valueOf(Math.max(
newFeeWithRate.subtract(oldFee).longValue(),
requiredFeeDelta
));
Coin remainingFeeDelta = feeDelta;
final List<TransactionOutput> origOuts = new ArrayList<>(tx.getOutputs());
tx.clearOutputs();
for (final JSONMap ep : txItem.eps) {
if (!ep.getBool("is_credit"))
continue;
if (!ep.getBool("is_relevant"))
// keep non-change/non-redeposit intact
tx.addOutput(origOuts.get(ep.getInt("pt_idx")));
else {